using System;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;

namespace UnityXEditor
{
    [Serializable]
    public class FFmpegSettings
    {
        [SerializeField]
        public bool m_Enabled = false;
        public void OnGUI()
        {
            m_Enabled = EditorGUILayout.Toggle("启用FFmpeg功能", m_Enabled);
        }
        public void Update()
        {
            CodeFileTool.CommentsLine("FFmpegTool.cs", "#define ENABLED", m_Enabled);
        }
        [PostProcessBuild()]
        public static void PostProcessBuild(BuildTarget target, string path)
        {
            if (target != BuildTarget.StandaloneWindows && target != BuildTarget.StandaloneWindows64)
                return;
            if (!UnityXSettings.platformSettings.windows.fFmpegSettings.m_Enabled)
                return;

            string sourceDir = Path.GetDirectoryName(EditorFileTool.GetFilePath("ffmpeg.exe"));
            string destDir = Path.GetDirectoryName(path) + "/" + Path.GetFileNameWithoutExtension(path) + "_Data/FFmpeg";

            EditorFileTool.CopyDirectory(sourceDir, destDir);
        }
    }
}